<extend name="Public/Dialog/Common"/>
<block name="pageContent">
    <div class="bjui-pageContent">
        <form action="{:U('update')}" class="pageForm" data-toggle="validate" method="post">
            <!-- 菜单id号 -->
            <input type="hidden" name="id" value="{$data.id|default=I('id')}"/>
            <input type="hidden" name="pid" value="{$data.pid|default=''}"/>
            <input type="hidden" name="model_id" value="{$data.model_id|default=I('model_id')}"/>
            <input type="hidden" name="group_id" value="{$data.group_id|default=''}"/>
            <if condition="$data['category_id']">
                <input type="hidden" name="category_id" value="{$data.category_id|default=''}">
            </if>
            <div class="col-md-8">
                <if condition="!$data['category_id']">
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                所属分类
                                <select name="category_id" data-toggle="selectpicker">
                                    <?php if($categoryList)foreach($categoryList as $arr):?>
                                    <option value="{$arr.id}"
                                    <?php echo $arr['id']==I('get.category_id')?'selected':'';?>>{$arr.title}</option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                        </div>
                    </div>
                </if>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            模板：<input type="text" value="{$data['template']}" name="template" class="text input-large form-control" size="50"> <span class="check-tips">（参照display方法参数的定义)</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            标题：<input type="text" value="{$data['title']}" name="title" class="text input-large form-control" size="50">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            来源：<input type="text" value="{$data['source']}" name="source"
                                      class="text input-large form-control" size="50">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            描述：<input type="text" value="{$data['description']}" name="description"
                                      class="text input-large form-control" size="50">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            内容
                        </div>
                        <div class="panel-body">
                            <textarea name="content" data-toggle="kindeditor"
                                      style="width: 100%;">{$data['content']}</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            封面
                        </div>
                        <div class="panel-body">
                            <div class="controls">
                                <input type="file" id="upload_picture_{$data.id}">
                                <input type="hidden" name="cover_id" value="{$data['cover_id']}"
                                       id="cover_id_{$data.id}"/>

                                <div class="upload-img-box">
                                    <notempty name="data['cover_id']">
                                        <div class="upload-pre-item">
                                            <img src="{$data['cover_id']|get_cover='path'}"
                                                 style="max-width:500px;max-height:200px;"/>
                                            <span onclick="delthispic{$data.id}(this)" dataid="{$v},"
                                                  class="fa fa-trash" style="font-size:20px;"></span>
                                        </div>
                                    </notempty>
                                </div>
                            </div>
                            <script type="text/javascript">
                                //上传单图
                                $.CurrentNavtab.find("#upload_picture_{$data.id}").uploadify({
                                    "height": 30,
                                    "swf": "__BJUI/plugins/uploadify/scripts/uploadify.swf",
                                    "fileObjName": "download",
                                    "buttonText": "上传图片",
                                    "uploader": "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                                    "width": 120,
                                    'removeTimeout': 1,
                                    'fileTypeExts': '*.jpg; *.png; *.gif;',
                                    "onUploadSuccess": function (file, data) {
                                        var data = $.parseJSON(data);
                                        var src = '';
                                        if (data.status) {
                                            $.CurrentNavtab.find("#cover_id_{$data.id}").val(data.id);
                                            src = data.url || '__ROOT' + data.path
                                            $.CurrentNavtab.find("#cover_id_{$data.id}").parent().find('.upload-img-box').html(
                                                    '<div class="upload-pre-item">' +
                                                    '<img src="' + src + '" style="max-width:500px;max-height:200px;"/>' +
                                                    '<span onclick="delthispic{$data.id}(this)" dataid="{$v}," class="fa fa-trash" style="font-size:20px;"></span>' +
                                                    '</div>'
                                            );
                                        } else {
                                            $(this).alertmsg('error', data.info);
                                        }
                                    },
                                    'onFallback': function () {
                                        alert('未检测到兼容版本的Flash.');
                                    }
                                });
                                /**
                                 * 删除单图, 更新数据
                                 */
                                function delthispic{$data.id}(obj)
                                {
                                    var dataids = '';   // 图片标识数据
                                    $(obj).parent().remove();               // 移除父结点
                                    // 更新数据
                                    $.CurrentNavtab.find('#cover_id_{$data.id}').val('');
                                }
                            </script>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            可见性
                        </div>
                        <div class="panel-body">
                            <volist name=":parse_field_attr($fields['display']['extra'])" id="vo">
                                <input type="radio" value="{$key}" name="display"
                                <eq name="data['display']" value="$key">checked="checked"</eq>
                                >{$vo}
                            </volist>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            推荐位
                        </div>
                        <div class="panel-body">
                            <volist name=":parse_field_attr($fields['position']['extra'])" id="vo">
                                <label><input type="checkbox" value="{$key}" name="position[]"
                                    <if condition="check_document_position($data['position'],$key)">checked="checked"
                                    </if>
                                    >{$vo}</label>
                            </volist>
                        </div>
                    </div>
                </div>
                <!--<div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            截至时间
                            <span class="check-tips">
                                （0-永久有效）
                            </span>
                        </div>
                        <div class="panel-body">
                            <input type="text" name="deadline" value="{$data['deadline']|date='Y-m-d',###}" data-toggle="datepicker" data-rule="date" placeholder="请选择日期" />
                        </div>
                    </div>
                </div>-->
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            创建时间
                        </div>
                        <div class="panel-body">
                            <input type="text" name="create_time" value="{$data['create_time']|time_format}"
                                   data-toggle="datepicker" data-rule="date" placeholder="请选择日期"/>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            收藏数
                        </div>
                        <div class="panel-body">
                            <input type="text" value="{$data['bookmark']}" name="bookmark"
                                   class="text input-mid form-control">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            评论数
                        </div>
                        <div class="panel-body">
                            <input type="text" value="{$data['comment']}" name="comment"
                                   class="text input-mid form-control">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            浏览量
                        </div>
                        <div class="panel-body">
                            <input type="text" value="{$data['view']}" name="view" class="text input-mid form-control">
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            标识
                        </div>
                        <div class="panel-body">
                            <input type="text" value="{$data['name']}" name="name"
                                   class="text input-large form-control">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</block>